package br.com.array.android.ma.view;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import br.com.array.android.ma.R;
import br.com.array.android.ma.controller.ItemMenuAdapter;
import br.com.array.android.ma.old.PrincipalActivity;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by desenvolv04 on 20/05/2014.
 */
public class MenuPrincipalActivity extends Activity {

    private ListView listView;
    private ItemMenuAdapter adapter;


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.menu_principal_activity);

        listView = (ListView) findViewById(R.id.lv_menu_principal);
        adapter = new ItemMenuAdapter(this, itens());
        listView.setAdapter(adapter);
        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Intent intent = new Intent(MenuPrincipalActivity.this, PrincipalActivity.class);
                intent.putExtra("posicao", position);
                startActivity(intent);
            }
        });

    }

    private List<ItemMenuModel> itens() {
        List<ItemMenuModel> itens = new ArrayList<ItemMenuModel>();
        itens.add(new ItemMenuModel(0, "Energia reativa", "Descrição do alarme de energia reativa."));
        itens.add(new ItemMenuModel(0, "Demanda", "Descrição do alarme de demanda."));
        itens.add(new ItemMenuModel(0, "Fator potência", "Descrição do alarme fator de potência."));
        return itens;
    }
}
